home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DartIntf.h
-
- Written by: Ken McLeod
-
- Copyright: © 1987-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Version: 1.5.3
- Created: Wednesday, August 3, 1994 16:00
-
- */
-
- #ifndef __DARTINTF__
- #define __DARTINTF__
-
- /*----------------------------------------------------------------------
- /*----------------------------------------------------------------------
-
- Some notes on reading a DART™ image file:
-
- DART™ is a program written by David Mutter and Ken McLeod of Apple
- Computer, Inc., for internal use in archiving and duplicating 3.5" floppy
- disks. Because of its utility in distributing compressed disk images on
- the Macintosh, DART™ is used in a number of Apple support products even
- though DART™ is not an official Apple product and is not supported as such.
-
- The format of a DART™ file is provided here for READ-ONLY use.
- No guarantees are expressed or implied. Use at your own risk.
-
- * * * * *
- File Header
- -----------
- The first word in the data fork of a DART™ file contains a compression
- identifier in the high byte (what type of compression is used), and a
- disk identifier in the low byte (what sort of disk this image contains).
- The second word contains the size of the source disk (e.g. 800=800K).
-
- From this info, you can decide whether to interpret the file header as
- a structure of type HDSrcInfoRec (for 1440K disks) or SrcInfoRec (for
- everything smaller than 1440K.) The difference is in the size of the
- block lengths array, bLength.
-
-
- How DART™ creates a disk image
- ------------------------------
- DART™ reads data from a 3.5" disk in blocks of 20480 bytes, starting with
- sector 0 and continuing sequentially to the end of the disk. Each block
- is read into a buffer capable of holding 20960 bytes. The remaining 480
- bytes at the end of the buffer are filled with tag data (or zeroed, if
- tags are not supported.) This 20960-byte buffer is then compressed and
- written to the end of the image file. Finally, the appropriate element of
- the block lengths array is updated with the compressed block length.
-
-
- Important note about compressed block lengths
- ---------------------------------------------
- Block lengths are always expressed in bytes, with the following two
- exceptions:
-
- 1) If the compression identifier is kRLECompress, the length of a
- compressed block is expressed in 16-bit words (or 2-byte units).
- Multiply by 2 to obtain the block size in bytes.
-
- 2) If the block length is -1, then the block isn't compressed and
- is assumed to be 20960 bytes.
-
-
- How to read a DART™ image file
- ------------------------------
- The basic procedure is to position the file mark at the end of the file
- header (which will either be sizeof(SrcInfoRec) or sizeof(HDSrcInfoRec)
- bytes), and read bLength[n] bytes from the file into a buffer. You then
- stream this compressed block through a decompression routine (either
- RLEExpandBlock() or LZHExpandBlock(), depending on the file's compression
- identifier) into a buffer capable of holding 20960 bytes. Remember that
- the first 20480 bytes are data, while the remaining 480 bytes are tags.
- Write out the data to disk, increment n, and repeat until bLength[n]==0
- or you reach the end of the file.
-
- Checksums
- ---------
- DART™ uses the same checksum algorithm as Disk Copy (another Apple disk
- utility) to verify the integrity of the disk data. The 32-bit checksums
- for data and tags are stored separately in the resource fork of the image
- file, rather than as part of the file header. The tag checksum is stored
- in resource 'CKSM' ID=1, and the data checksum is stored in 'CKSM' ID=2.
-
-
- /*----------------------------------------------------------------------
- /*----------------------------------------------------------------------
- disk identifiers
- /*----------------------------------------------------------------------*/
-
- #define kMacDisk 1
- #define kLisaDisk 2
- #define kAppleIIDisk 3
-
- #define kMacHiDDisk 16
- #define kMSDOSLowDDisk 17
- #define kMSDOSHiDDisk 18
-
- /*----------------------------------------------------------------------
- file types
- /*----------------------------------------------------------------------*/
-
- #define kDartCreator 'DART'
- #define kOldFileType 'DMdf'
- #define kDartPrefsType 'DMd0'
- #define kMac400KType 'DMd1'
- #define kLisa400KType 'DMd2'
- #define kMac800KType 'DMd3'
- #define kApple800KType 'DMd4'
- #define kMSDOS720KType 'DMd5'
- #define kMac1440KType 'DMd6'
- #define kMSDOS1440KType 'DMd7'
- #define kDiskCopyType 'dImg'
-
- /*----------------------------------------------------------------------
- compression identifiers
- /*----------------------------------------------------------------------*/
-
- #define kRLECompress 0 /* "fast" algorithm */
- #define kLZHCompress 1 /* "best" algorithm */
- #define kNoCompress 2 /* not compressed */
-
- /*----------------------------------------------------------------------
- data structures
- /*----------------------------------------------------------------------*/
-
- typedef unsigned char uchar;
- typedef unsigned short ushort;
- typedef unsigned long ulong;
-
- typedef struct SrcInfoRec
- {
- uchar srcCmp; /* compression identifier */
- uchar srcType; /* disk type identifier (Lisa, Mac, etc.) */
- short srcSize; /* size of source disk in Kb (e.g. 800=800K) */
- short bLength[40]; /* array of block lengths */
- /* variable-length compressed disk data follows... */
- } SrcInfoRec;
-
- typedef struct HDSrcInfoRec
- {
- uchar srcCmp; /* compression identifier */
- uchar srcType; /* disk type identifier (Lisa, Mac, etc.) */
- short srcSize; /* size of source disk in Kb (e.g. 800=800K) */
- short bLength[72]; /* array of block lengths */
- /* variable-length compressed disk data follows... */
- } HDSrcInfoRec;
-
-
- #define DDBLOCKSIZE 20960 /* size of an uncompressed block, in bytes */
-
- typedef uchar DiskData[DDBLOCKSIZE], *DDPtr;
-
-
- /*----------------------------------------------------------------------
- library functions
- /*----------------------------------------------------------------------*/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- pascal OSErr RLEExpandBlock(Ptr theBlock, DDPtr outputBuf, short blockLen);
- pascal OSErr LZHExpandBlock(Ptr theBlock, DDPtr outputBuf, short blockLen);
-
- #ifdef __cplusplus
- }
- #endif
-
-
- #endif __DARTINTF__